home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / LEMACS.9 (.txt) < prev    next >
GNU Info File  |  1994-09-21  |  49KB  |  858 lines

  1. This is Info file ../info/lemacs, produced by Makeinfo-1.55 from the
  2. input file lemacs.txi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  5. 1991, 1992 Lucid, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided also
  11. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  12. General Public License" are included exactly as in the original, and
  13. provided that the entire resulting derived work is distributed under the
  14. terms of a permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that the sections entitled "The GNU Manifesto",
  18. "Distribution" and "GNU General Public License" may be included in a
  19. translation approved by the author instead of in the original English.
  20. File: lemacs,  Node: Comments,  Next: Balanced Editing,  Prev: Matching,  Up: Programs
  21. Manipulating Comments
  22. =====================
  23.    The comment commands insert, kill and align comments.
  24. `M-;'
  25.      Insert or align comment (`indent-for-comment').
  26. `C-x ;'
  27.      Set comment column (`set-comment-column').
  28. `C-u - C-x ;'
  29.      Kill comment on current line (`kill-comment').
  30. `M-LFD'
  31.      Like RET followed by inserting and aligning a comment
  32.      (`indent-new-comment-line').
  33.    The command that creates a comment is `Meta-;'
  34. (`indent-for-comment').  If there is no comment already on the line, a
  35. new comment is created and aligned at a specific column called the
  36. "comment column".  Emacs creates the comment by inserting the string at
  37. the value of `comment-start'; see below.  Point is left after that
  38. string.  If the text of the line extends past the comment column,
  39. indentation is done to a suitable boundary (usually, at least one space
  40. is inserted).  If the major mode has specified a string to terminate
  41. comments, that string is inserted after point, to keep the syntax valid.
  42.    You can also use `Meta-;' to align an existing comment.  If a line
  43. already contains the string that starts comments, `M-;' just moves
  44. point after it and re-indents it to the conventional place.  Exception:
  45. comments starting in column 0 are not moved.
  46.    Some major modes have special rules for indenting certain kinds of
  47. comments in certain contexts.  For example, in Lisp code, comments which
  48. start with two semicolons are indented as if they were lines of code,
  49. instead of at the comment column.  Comments which start with three
  50. semicolons are supposed to start at the left margin.  Emacs understands
  51. these conventions by indenting a double-semicolon comment using TAB,
  52. and by not changing the indentation of a triple-semicolon comment at
  53.      ;; This function is just an example
  54.      ;;; Here either two or three semicolons are appropriate.
  55.      (defun foo (x)
  56.      ;;; And now, the first part of the function:
  57.        ;; The following line adds one.
  58.        (1+ x))           ; This line adds one.
  59.    In C code, a comment preceded on its line by nothing but whitespace
  60. is indented like a line of code.
  61.    Even when an existing comment is properly aligned, `M-;' is still
  62. useful for moving directly to the start of the comment.
  63.    `C-u - C-x ;' (`kill-comment') kills the comment on the current
  64. line, if there is one.  The indentation before the start of the comment
  65. is killed as well.  If there does not appear to be a comment in the
  66. line, nothing happens.  To reinsert the comment on another line, move
  67. to the end of that line, type first `C-y', and then `M-;' to realign
  68. the comment.  Note that `C-u - C-x ;' is not a distinct key; it is `C-x
  69. ;' (`set-comment-column') with a negative argument.  That command is
  70. programmed to call `kill-comment' when called with a negative argument.
  71. However, `kill-comment' is a valid command which you could bind
  72. directly to a key if you wanted to.
  73. Multiple Lines of Comments
  74. --------------------------
  75.    If you are typing a comment and want to continue it on another line,
  76. use the command `Meta-LFD' (`indent-new-comment-line'), which
  77. terminates the comment you are typing, creates a new blank line
  78. afterward, and begins a new comment indented under the old one.  If
  79. Auto Fill mode is on and you go past the fill column while typing, the
  80. comment is continued in just this fashion.  If point is not at the end
  81. of the line when you type `M-LFD', the text on the rest of the line
  82. becomes part of the new comment line.
  83. Options Controlling Comments
  84. ----------------------------
  85.    The comment column is stored in the variable `comment-column'.  You
  86. can explicitly set it to a number.  Alternatively, the command `C-x ;'
  87. (`set-comment-column') sets the comment column to the column point is
  88. at.  `C-u C-x ;' sets the comment column to match the last comment
  89. before point in the buffer, and then calls `Meta-;' to align the
  90. current line's comment under the previous one.  Note that `C-u - C-x ;'
  91. runs the function `kill-comment' as described above.
  92.    `comment-column' is a per-buffer variable; altering the variable
  93. affects only the current buffer.  You can also change the default value.
  94. *Note Locals::.  Many major modes initialize this variable for the
  95. current buffer.
  96.    The comment commands recognize comments based on the regular
  97. expression that is the value of the variable `comment-start-skip'.
  98. This regexp should not match the null string.  It may match more than
  99. the comment starting delimiter in the strictest sense of the word; for
  100. example, in C mode the value of the variable is `"/\\*+ *"', which
  101. matches extra stars and spaces after the `/*' itself.  (Note that `\\'
  102. is needed in Lisp syntax to include a `\' in the string, which is needed
  103. to deny the first star its special meaning in regexp syntax.  *Note
  104. Regexps::.)
  105.    When a comment command makes a new comment, it inserts the value of
  106. `comment-start' to begin it.  The value of `comment-end' is inserted
  107. after point, and will follow the text you will insert into the comment.
  108. In C mode, `comment-start' has the value `"/* "' and `comment-end' has
  109. the value `" */"'.
  110.    `comment-multi-line' controls how `M-LFD'
  111. (`indent-new-comment-line') behaves when used inside a comment.  If
  112. `comment-multi-line' is `nil', as it normally is, then `M-LFD'
  113. terminates the comment on the starting line and starts a new comment on
  114. the new following line.  If `comment-multi-line' is not `nil', then
  115. `M-LFD' sets up the new following line as part of the same comment that
  116. was found on the starting line.  This is done by not inserting a
  117. terminator on the old line, and not inserting a starter on the new
  118. line.  In languages where multi-line comments are legal, the value you
  119. choose for this variable is a matter of taste.
  120.    The variable `comment-indent-hook' should contain a function that is
  121. called to compute the indentation for a newly inserted comment or for
  122. aligning an existing comment.  Major modes set this variable
  123. differently.  The function is called with no arguments, but with point
  124. at the beginning of the comment, or at the end of a line if a new
  125. comment is to be inserted.  The function should return the column in
  126. which the comment ought to start.  For example, in Lisp mode, the
  127. indent hook function bases its decision on the number of semicolons
  128. that begin an existing comment, and on the code in the preceding lines.
  129. File: lemacs,  Node: Balanced Editing,  Next: Lisp Completion,  Prev: Comments,  Up: Programs
  130. Editing Without Unbalanced Parentheses
  131. ======================================
  132. `M-('
  133.      Put parentheses around next sexp(s) (`insert-parentheses').
  134. `M-)'
  135.      Move past next close parenthesis and re-indent
  136.      (`move-over-close-and-reindent').
  137.    The commands `M-(' (`insert-parentheses') and `M-)'
  138. (`move-over-close-
  139. and-reindent') are designed to facilitate a style of editing which
  140. keeps parentheses balanced at all times.  `M-(' inserts a pair of
  141. parentheses, either together as in `()', or, if given an argument,
  142. around the next several sexps, and leaves point after the open
  143. parenthesis.  Instead of typing `( F O O )', you can type `M-( F O O',
  144. which has the same effect except for leaving the cursor before the
  145. close parenthesis.  You can then type `M-)', which moves past the close
  146. parenthesis, deletes any indentation preceding it (in this example
  147. there is none), and indents with LFD after it.
  148. File: lemacs,  Node: Lisp Completion,  Next: Documentation,  Prev: Balanced Editing,  Up: Programs
  149. Completion for Lisp Symbols
  150. ===========================
  151.    Completion usually happens in the minibuffer.  An exception is
  152. completion for Lisp symbol names, which is available in all buffers.
  153.    The command `M-TAB' (`lisp-complete-symbol') takes the partial Lisp
  154. symbol before point to be an abbreviation, and compares it against all
  155. non-trivial Lisp symbols currently known to Emacs.  Any additional
  156. characters that they all have in common are inserted at point.
  157. Non-trivial symbols are those that have function definitions, values or
  158. properties.
  159.    If there is an open-parenthesis immediately before the beginning of
  160. the partial symbol, only symbols with function definitions are
  161. considered as completions.
  162.    If the partial name in the buffer has more than one possible
  163. completion and they have no additional characters in common, a list of
  164. all possible completions is displayed in another window.
  165. File: lemacs,  Node: Documentation,  Next: Change Log,  Prev: Lisp Completion,  Up: Programs
  166. Documentation Commands
  167. ======================
  168.    As you edit Lisp code to be run in Emacs, you can use the commands
  169. `C-h f' (`describe-function') and `C-h v' (`describe-variable') to
  170. print documentation of functions and variables you want to call.  These
  171. commands use the minibuffer to read the name of a function or variable
  172. to document, and display the documentation in a window.
  173.    For extra convenience, these commands provide default arguments
  174. based on the code in the neighborhood of point.  `C-h f' sets the
  175. default to the function called in the innermost list containing point.
  176. `C-h v' uses the symbol name around or adjacent to point as its default.
  177.    The `M-x manual-entry' command gives you access to documentation on
  178. Unix commands, system calls, and libraries.  The command reads a topic
  179. as an argument, and displays the Unix manual page for that topic.
  180. `manual-entry' always searches all 8 sections of the manual, and
  181. concatenates all the entries it finds.  For example, the topic
  182. `termcap' finds the description of the termcap library from section 3,
  183. followed by the description of the termcap data base from section 5.
  184. File: lemacs,  Node: Change Log,  Next: Tags,  Prev: Documentation,  Up: Programs
  185. Change Logs
  186. ===========
  187.    The Emacs command `M-x add-change-log-entry' helps you keep a record
  188. of when and why you have changed a program.  It assumes that you have a
  189. file in which you write a chronological sequence of entries describing
  190. individual changes.  The default is to store the change entries in a
  191. file called `ChangeLog' in the same directory as the file you are
  192. editing.  The same `ChangeLog' file therefore records changes for all
  193. the files in a directory.
  194.    A change log entry starts with a header line that contains your name
  195. and the current date.  Except for these header lines, every line in the
  196. change log starts with a tab.  One entry can describe several changes;
  197. each change starts with a line starting with a tab and a star.  `M-x
  198. add-change-log-entry' visits the change log file and creates a new entry
  199. unless the most recent entry is for today's date and your name.  In
  200. either case, it adds a new line to start the description of another
  201. change just after the header line of the entry.  When `M-x
  202. add-change-log-entry' is finished, all is prepared for you to edit in
  203. the description of what you changed and how.  You must then save the
  204. change log file yourself.
  205.    The change log file is always visited in Indented Text mode, which
  206. means that LFD and auto-filling indent each new line like the previous
  207. line.  This is convenient for entering the contents of an entry, which
  208. must be indented.  *Note Text Mode::.
  209.    Here is an example of the formatting conventions used in the change
  210. log for Emacs:
  211.      Wed Jun 26 19:29:32 1985  Richard M. Stallman  (rms at mit-prep)
  212.      
  213.              * xdisp.c (try_window_id):
  214.              If C-k is done at end of next-to-last line,
  215.              this fn updates window_end_vpos and cannot leave
  216.              window_end_pos nonnegative (it is zero, in fact).
  217.              If display is preempted before lines are output,
  218.              this is inconsistent.  Fix by setting
  219.              blank_end_of_window to nonzero.
  220.      
  221.      Tue Jun 25 05:25:33 1985  Richard M. Stallman  (rms at mit-prep)
  222.      
  223.              * cmds.c (Fnewline):
  224.              Call the auto fill hook if appropriate.
  225.      
  226.              * xdisp.c (try_window_id):
  227.              If point is found by compute_motion after xp, record that
  228.              permanently.  If display_text_line sets point position wrong
  229.              (case where line is killed, point is at eob and that line is
  230.              not displayed), set it again in final compute_motion.
  231. File: lemacs,  Node: Tags,  Next: Fortran,  Prev: Change Log,  Up: Programs
  232. Tag Tables
  233. ==========
  234.    A "tag table" is a description of how a multi-file program is broken
  235. up into files.  It lists the names of the component files and the names
  236. and positions of the functions in each file.  Grouping the related
  237. files makes it possible to search or replace through all the files with
  238. one command.  Recording the function names and positions makes it
  239. possible to use the `Meta-.' command which finds the definition of a
  240. function without asking for information on the file it is in.
  241.    Tag tables are stored in files called "tag table files".  The
  242. conventional name for a tag table file is `TAGS'.
  243.    Each entry in the tag table records the name of one tag, the name of
  244. the file that the tag is defined in (implicitly), and the position in
  245. that file of the tag's definition.
  246.    The programming language of a file determines what names are recorded
  247. in the tag table depends on.  Normally, Emacs includes all functions and
  248. subroutines, and may also include global variables, data types, and
  249. anything else convenient.  Each recorded name is called a "tag".
  250. * Menu:
  251. * Tag Syntax::
  252. * Create Tag Table::
  253. * Select Tag Table::
  254. * Find Tag::
  255. * Tags Search::
  256. * Tags Stepping::
  257. * List Tags::
  258. File: lemacs,  Node: Tag Syntax,  Next: Create Tag Table,  Prev: Tags,  Up: Tags
  259. Source File Tag Syntax
  260. ----------------------
  261.    In Lisp code, any function defined with `defun', any variable
  262. defined with `defvar' or `defconst', and the first argument of any
  263. expression that starts with `(def' in column zero, is a tag.
  264.    In C code, any C function is a tag, and so is any typedef if `-t' is
  265. specified when the tag table is constructed.
  266.    In Fortran code, functions and subroutines are tags.
  267.    In LaTeX text, the argument of any of the commands `\chapter',
  268. `\section', `\subsection', `\subsubsection', `\eqno', `\label', `\ref',
  269. `\cite', `\bibitem' and
  270. `\typeout' is a tag.
  271. File: lemacs,  Node: Create Tag Table,  Next: Select Tag Table,  Prev: Tag Syntax,  Up: Tags
  272. Creating Tag Tables
  273. -------------------
  274.    The `etags' program is used to create a tag table file.  It knows
  275. the syntax of C, Fortran, LaTeX, Scheme and Emacs Lisp/Common Lisp.  To
  276. use `etags', use it as a shell command
  277.      etags INPUTFILES...
  278. The program reads the specified files and writes a tag table named
  279. `TAGS' in the current working directory.  `etags' recognizes the
  280. language used in an input file based on the name and contents of the
  281. file; there are no switches for specifying the language.  The `-t'
  282. switch tells `etags' to record typedefs in C code as tags.
  283.    If the tag table data become outdated due to changes in the files
  284. described in the table, you can update the tag table by running the
  285. program from the shell again.  It is not necessary to do this often.
  286.    If the tag table fails to record a tag, or records it for the wrong
  287. file, Emacs cannot find its definition.  However, if the position
  288. recorded in the tag table becomes a little bit wrong (due to some
  289. editing in the file that the tag definition is in), the only
  290. consequence is to slow down finding the tag slightly.  Even if the
  291. stored position is very wrong, Emacs will still find the tag, but it
  292. must search the entire file for it.
  293.    You should update a tag table when you define new tags you want to
  294. have listed, or when you move tag definitions from one file to another,
  295. or when changes become substantial.  You don't have to update the tag
  296. table after each edit, or even every day.
  297. File: lemacs,  Node: Select Tag Table,  Next: Find Tag,  Prev: Create Tag Table,  Up: Tags
  298. Selecting a Tag Table
  299. ---------------------
  300.    At any time Emacs has one "selected" tag table, and all the commands
  301. for working with tag tables use the selected one.  To select a tag
  302. table, use the variable `tag-table-alist'.
  303.    The value of `tag-table-alist' is a list that determines which
  304. `TAGS' files should be active for a given buffer.  This is not really
  305. an association list, in that all elements are checked.  The car of each
  306. element of this list is a pattern against which the buffers file name
  307. is compared; if it matches, then the cdr of the list should be the name
  308. of the tags table to use.  If more than one element of this list
  309. matches the buffers file name, all of the associated tags tables are
  310. used.  Earlier ones are searched first.
  311.    If the car of elements of this list are strings, they are treated as
  312. regular-expressions against which the file is compared (like the
  313. `auto-mode-alist').  If they are not strings, they are evaluated.  If
  314. they evaluate to non-`nil', the current buffer is considered to match.
  315.    If the cdr of the elements of this list are strings, they are
  316. assumed to name a tags file.  If they name a directory, the string
  317. `tags' is appended to them to get the file name.  If they are not
  318. strings, they are evaluated, and must return an appropriate string.
  319.    For example:
  320.        (setq tag-table-alist
  321.          (("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
  322.           ("\\.el$" . "/usr/local/emacs/src/")
  323.           ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
  324.           ("" . "/usr/local/emacs/src/")
  325.           ))
  326.    The example defines the tag table alist in the following way:
  327.    * Anything in the directory `/usr/src/public/perl/' should use the
  328.      `TAGS' file `/usr/src/public/perl/perl-3.0/TAGS'.
  329.    * Files ending in `.el' should use the `TAGS' file
  330.      `/usr/local/emacs/src/TAGS'.
  331.    * Anything in or below the directory `/jbw/gnu/' should use the
  332.      `TAGS' file `/usr15/degree/stud/jbw/gnu/TAGS'.
  333.    If you had a file called `/usr/jbw/foo.el', it would use both `TAGS'
  334. files,
  335. `/usr/local/emacs/src/TAGS' and `/usr15/degree/stud/jbw/gnu/TAGS' (in
  336. that order), because it matches both patterns.
  337.    If the buffer-local variable `buffer-tag-table' is set, it names a
  338. tags table that is searched before all others when `find-tag' is
  339. executed from this buffer.
  340.    If there is a file called `TAGS' in the same directory as the file
  341. in question, then that tags file will always be used as well (after the
  342. `buffer-tag-table' but before the tables specified by this list).
  343.    If the variable `tags-file-name' is set, the `TAGS' file it names
  344. will apply to all buffers (for backwards compatibility.)  It is searched
  345. first.
  346.    If the value of the variable `tags-always-build-completion-table' is
  347. `t', the tags file will always be added to the completion table without
  348. asking first, regardless of the size of the tags file.
  349.    The function `M-x visit-tags-table', which is largely obsoleted by
  350. the variable `tag-table-alist', tells tags commands to use the tags
  351. table file FILE first.  The FILE should be the name of a file created
  352. with the `etags' program.  A directory name is also acceptable; it
  353. means the file `TAGS' in that directory.  The function only stores the
  354. file name you provide in the variable `tags-file-name'.  Emacs does not
  355. actually read in the tag table contents until you try to use them.  You
  356. can set the variable explicitly instead of using `visit-tags-table'.
  357. The value of the variable `tags-file-name' is the name of the tags
  358. table used by all buffers.  This is for backward compatibility, and is
  359. largely supplanted by the variable `tag-table-alist'.
  360. File: lemacs,  Node: Find Tag,  Next: Tags Search,  Prev: Select Tag Table,  Up: Tags
  361. Finding a Tag
  362. -------------
  363.    The most important thing that a tag table enables you to do is to
  364. find the definition of a specific tag.
  365. `M-. TAG &OPTIONAL OTHER-WINDOW'
  366.      Find first definition of TAG (`find-tag').
  367. `C-u M-.'
  368.      Find next alternate definition of last tag specified.
  369. `C-x 4 . TAG'
  370.      Find first definition of TAG, but display it in another window
  371.      (`find-tag-other-window').
  372.    `M-.' (`find-tag') is the command to find the definition of a
  373. specified tag.  It searches through the tag table for that tag, as a
  374. string, then uses the tag table information to determine the file in
  375. which the definition is used and the approximate character position of
  376. the definition in the file.  Then `find-tag' visits the file, moves
  377. point to the approximate character position, and starts searching
  378. ever-increasing distances away for the text that should appear at the
  379. beginning of the definition.
  380.    If an empty argument is given (just type RET), the sexp in the
  381. buffer before or around point is used as the name of the tag to find.
  382. *Note Lists::, for information on sexps.
  383.    The argument to `find-tag' need not be the whole tag name; it can be
  384. a substring of a tag name.  However, there can be many tag names
  385. containing the substring you specify.  Since `find-tag' works by
  386. searching the text of the tag table, it finds the first tag in the table
  387. that the specified substring appears in.  To find other tags that match
  388. the substring, give `find-tag' a numeric argument, as in `C-u M-.'.
  389. This does not read a tag name, but continues searching the tag table's
  390. text for another tag containing the same substring last used.  If your
  391. keyboard has a real META key, `M-0 M-.' is an easier alternative to
  392. `C-u M-.'.
  393.    If the optional second argument OTHER-WINDOW is non-`nil', it uses
  394. another window to display the tag.  Multiple active tags tables and
  395. completion are supported.
  396.    Variables of note:
  397. `tag-table-alist'
  398.      Controls which tables apply to which buffers.
  399. `tags-file-name'
  400.      Stores a default tags table.
  401. `tags-build-completion-table'
  402.      Controls completion behavior.
  403. `buffer-tag-table'
  404.      Specifies a buffer-local table.
  405. `make-tags-files-invisible'
  406.      Sets whether tags tables should be very hidden.
  407. `tag-mark-stack-max'
  408.      Specifies how many tags-based hops to remember.
  409.    Like most commands that can switch buffers, `find-tag' has another
  410. similar command that displays the new buffer in another window.  `C-x 4
  411. .' invokes the function `find-tag-other-window'.  (This key sequence
  412. ends with a period.)
  413.    Emacs comes with a tag table file `TAGS', in the directory
  414. containing Lisp libraries, which includes all the Lisp libraries and all
  415. the C sources of Emacs.  By specifying this file with `visit-tags-table'
  416. and then using `M-.' you can quickly look at the source of any Emacs
  417. function.
  418. File: lemacs,  Node: Tags Search,  Next: Tags Stepping,  Prev: Find Tag,  Up: Tags
  419. Searching and Replacing with Tag Tables
  420. ---------------------------------------
  421.    The commands in this section visit and search all the files listed
  422. in the selected tag table, one by one.  For these commands, the tag
  423. table serves only to specify a sequence of files to search.  A related
  424. command is `M-x grep' (*note Compilation::.).
  425. `M-x tags-search'
  426.      Search for the specified regexp through the files in the selected
  427.      tag table.
  428. `M-x tags-query-replace'
  429.      Perform a `query-replace' on each file in the selected tag table.
  430. `M-,'
  431.      Restart one of the commands above, from the current location of
  432.      point (`tags-loop-continue').
  433.    `M-x tags-search' reads a regexp using the minibuffer, then visits
  434. the files of the selected tag table one by one, and searches through
  435. each file for that regexp.  It displays the name of the file being
  436. searched so you can follow its progress.  As soon as an occurrence is
  437. found, `tags-search' returns.
  438.    After you have found one match, you probably want to find all the
  439. rest.  To find one more match, type `M-,' (`tags-loop-continue') to
  440. resume the `tags-search'.  This searches the rest of the current
  441. buffer, followed by the remaining files of the tag table.
  442.    `M-x tags-query-replace' performs a single `query-replace' through
  443. all the files in the tag table.  It reads a string to search for and a
  444. string to replace with, just like ordinary `M-x query-replace'.  It
  445. searches much like `M-x tags-search' but repeatedly, processing matches
  446. according to your input.  *Note Replace::, for more information on
  447. `query-replace'.
  448.    It is possible to get through all the files in the tag table with a
  449. single invocation of `M-x tags-query-replace'.  But since any
  450. unrecognized character causes the command to exit, you may need to
  451. continue where you left off.  You can use `M-,' to do this.  It resumes
  452. the last tags search or replace command that you did.
  453.    It may have struck you that `tags-search' is a lot like `grep'.  You
  454. can also run `grep' itself as an inferior of Emacs and have Emacs show
  455. you the matching lines one by one.  This works mostly the same as
  456. running a compilation and having Emacs show you where the errors were.
  457. *Note Compilation::.
  458. File: lemacs,  Node: Tags Stepping,  Next: List Tags,  Prev: Tags Search,  Up: Tags
  459. Stepping Through a Tag Table
  460. ----------------------------
  461.    If you wish to process all the files in a selected tag table, but
  462. `M-x tags-search' and `M-x tags-query-replace' are not giving you the
  463. desired result, you can use `M-x next-file'.
  464. `C-u M-x next-file'
  465.      With a numeric argument, regardless of its value, visit the first
  466.      file in the tag table, and prepare to advance sequentially by
  467.      files.
  468. `M-x next-file'
  469.      Visit the next file in the selected tag table.
  470. File: lemacs,  Node: List Tags,  Prev: Tags Stepping,  Up: Tags
  471. Tag Table Inquiries
  472. -------------------
  473. `M-x list-tags'
  474.      Display a list of the tags defined in a specific program file.
  475. `M-x tags-apropos'
  476.      Display a list of all tags matching a specified regexp.
  477.    `M-x list-tags' reads the name of one of the files described by the
  478. selected tag table, and displays a list of all the tags defined in that
  479. file.  The "file name" argument is really just a string to compare
  480. against the names recorded in the tag table; it is read as a string
  481. rather than a file name.  Therefore, completion and defaulting are not
  482. available, and you must enter the string the same way it appears in the
  483. tag table.  Do not include a directory as part of the file name unless
  484. the file name recorded in the tag table contains that directory.
  485.    `M-x tags-apropos' is like `apropos' for tags.  It reads a regexp,
  486. then finds all the tags in the selected tag table whose entries match
  487. that regexp, and displays the tag names found.
  488. File: lemacs,  Node: Fortran,  Prev: Tags,  Up: Programs
  489. Fortran Mode
  490. ============
  491.    Fortran mode provides special motion commands for Fortran statements
  492. and subprograms, and indentation commands that understand Fortran
  493. conventions of nesting, line numbers and continuation statements.
  494.    Special commands for comments are provided because Fortran comments
  495. are unlike those of other languages.
  496.    Built-in abbrevs optionally save typing when you insert Fortran
  497. keywords.
  498.    Use `M-x fortran-mode' to switch to this major mode.  Doing so calls
  499. the value of `fortran-mode-hook' as a function of no arguments if that
  500. variable has a non- `nil' value.
  501. * Menu:
  502. * Motion: Fortran Motion.     Moving point by statements or subprograms.
  503. * Indent: Fortran Indent.     Indentation commands for Fortran.
  504. * Comments: Fortran Comments. Inserting and aligning comments.
  505. * Columns: Fortran Columns.   Measuring columns for valid Fortran.
  506. * Abbrev: Fortran Abbrev.     Built-in abbrevs for Fortran keywords.
  507.    Fortran mode was contributed by Michael Prange.
  508. File: lemacs,  Node: Fortran Motion,  Next: Fortran Indent,  Prev: Fortran,  Up: Fortran
  509. Motion Commands
  510. ---------------
  511.    Fortran mode provides special commands to move by subprograms
  512. (functions and subroutines) and by statements.  There is also a command
  513. to put the region around one subprogram, convenient for killing it or
  514. moving it.
  515. `C-M-a'
  516.      Move to beginning of subprogram
  517.      (`beginning-of-fortran-subprogram').
  518. `C-M-e'
  519.      Move to end of subprogram (`end-of-fortran-subprogram').
  520. `C-M-h'
  521.      Put point at beginning of subprogram and mark at end
  522.      (`mark-fortran-subprogram').
  523. `C-c C-n'
  524.      Move to beginning of current or next statement (`fortran-next-
  525.      statement').
  526. `C-c C-p'
  527.      Move to beginning of current or previous statement (`fortran-
  528.      previous-statement').
  529. File: lemacs,  Node: Fortran Indent,  Next: Fortran Comments,  Prev: Fortran Motion,  Up: Fortran
  530. Fortran Indentation
  531. -------------------
  532.    Special commands and features are available for indenting Fortran
  533. code.  They make sure various syntactic entities (line numbers, comment
  534. line indicators and continuation line flags) appear in the columns that
  535. are required for standard Fortran.
  536. * Menu:
  537. * Commands: ForIndent Commands. Commands for indenting Fortran.
  538. * Numbers:  ForIndent Num.      How line numbers auto-indent.
  539. * Conv:     ForIndent Conv.     Conventions you must obey to avoid trouble.
  540. * Vars:     ForIndent Vars.     Variables controlling Fortran indent style.
  541. File: lemacs,  Node: ForIndent Commands,  Next: ForIndent Num,  Prev: Fortran Indent,  Up: Fortran Indent
  542. Fortran Indentation Commands
  543. ............................
  544. `TAB'
  545.      Indent the current line (`fortran-indent-line').
  546. `M-LFD'
  547.      Break the current line and set up a continuation line.
  548. `C-M-q'
  549.      Indent all the lines of the subprogram point is in
  550.      (`fortran-indent-subprogram').
  551.    TAB is redefined by Fortran mode to reindent the current line for
  552. Fortran (`fortran-indent-line').  Line numbers and continuation markers
  553. are indented to their required columns, and the body of the statement
  554. is independently indented based on its nesting in the program.
  555.    The key `C-M-q' is redefined as `fortran-indent-subprogram', a
  556. command that reindents all the lines of the Fortran subprogram
  557. (function or subroutine) containing point.
  558.    The key `M-LFD' is redefined as `fortran-split-line', a command to
  559. split a line in the appropriate fashion for Fortran.  In a non-comment
  560. line, the second half becomes a continuation line and is indented
  561. accordingly.  In a comment line, both halves become separate comment
  562. lines.
  563. File: lemacs,  Node: ForIndent Num,  Next: ForIndent Conv,  Prev: ForIndent Commands,  Up: Fortran Indent
  564. Line Numbers and Continuation
  565. .............................
  566.    If a number is the first non-whitespace in the line, it is assumed
  567. to be a line number and is moved to columns 0 through 4.  (Columns are
  568. always counted from 0 in GNU Emacs.)  If the text on the line starts
  569. with the conventional Fortran continuation marker `$', it is moved to
  570. column 5.  If the text begins with any non whitespace character in
  571. column 5, it is assumed to be an unconventional continuation marker and
  572. remains in column 5.
  573.    Line numbers of four digits or less are normally indented one space.
  574. This amount is controlled by the variable `fortran-line-number-indent'
  575. which is the maximum indentation a line number can have.  Line numbers
  576. are indented to right-justify them to end in column 4 unless that would
  577. require more than the maximum indentation.  The default value of the
  578. variable is 1.
  579.    Simply inserting a line number is enough to indent it according to
  580. these rules.  As each digit is inserted, the indentation is recomputed.
  581. To turn off this feature, set the variable
  582. `fortran-electric-line-number' to `nil'.  Then inserting line numbers
  583. is like inserting anything else.
  584. File: lemacs,  Node: ForIndent Conv,  Next: ForIndent Vars,  Prev: ForIndent Num,  Up: Fortran Indent
  585. Syntactic Conventions
  586. .....................
  587.    Fortran mode assumes that you follow certain conventions that
  588. simplify the task of understanding a Fortran program well enough to
  589. indent it properly:
  590.    * Two nested `do' loops never share a `continue' statement.
  591.    * The same character appears in column 5 of all continuation lines.
  592.      It is the value of the variable `fortran-continuation-char'.  By
  593.      default, this character is `$'.
  594. If you fail to follow these conventions, the indentation commands may
  595. indent some lines unaesthetically.  However, a correct Fortran program
  596. will retain its meaning when reindented even if the conventions are not
  597. followed.
  598. File: lemacs,  Node: ForIndent Vars,  Prev: ForIndent Conv,  Up: Fortran Indent
  599. Variables for Fortran Indentation
  600. .................................
  601.    Several additional variables control how Fortran indentation works.
  602. `fortran-do-indent'
  603.      Extra indentation within each level of `do' statement (default 3).
  604. `fortran-if-indent'
  605.      Extra indentation within each level of `if' statement (default 3).
  606. `fortran-continuation-indent'
  607.      Extra indentation for bodies of continuation lines (default 5).
  608. `fortran-check-all-num-for-matching-do'
  609.      If this is `nil', indentation assumes that each `do' statement
  610.      ends on a `continue' statement.  Therefore, when computing
  611.      indentation for a statement other than `continue', it can save
  612.      time by not checking for a `do' statement ending there.  If this
  613.      is non-`nil', indenting any numbered statement must check for a
  614.      `do' that ends there.  The default is `nil'.
  615. `fortran-minimum-statement-indent'
  616.      Minimum indentation for Fortran statements.  For standard Fortran,
  617.      this is 6.  Statement bodies are always indented at least this
  618.      much.
  619. File: lemacs,  Node: Fortran Comments,  Next: Fortran Columns,  Prev: Fortran Indent,  Up: Fortran
  620. Comments
  621. --------
  622.    The usual Emacs comment commands assume that a comment can follow a
  623. line of code.  In Fortran, the standard comment syntax requires an
  624. entire line to be just a comment.  Therefore, Fortran mode replaces the
  625. standard Emacs comment commands and defines some new variables.
  626.    Fortran mode can also handle a non-standard comment syntax where
  627. comments start with `!' and can follow other text.  Because only some
  628. Fortran compilers accept this syntax, Fortran mode will not insert such
  629. comments unless you have specified to do so in advance by setting the
  630. variable `comment-start' to `"!"' (*note Variables::.).
  631. `M-;'
  632.      Align comment or insert new comment (`fortran-comment-indent').
  633. `C-x ;'
  634.      Applies to nonstandard `!' comments only.
  635. `C-c ;'
  636.      Turn all lines of the region into comments, or (with arg) turn
  637.      them back into real code (`fortran-comment-region').
  638.    `M-;' in Fortran mode is redefined as the command
  639. `fortran-comment-indent'.  Like the usual `M-;' command, recognizes an
  640. existing comment and aligns its text appropriately.  If there is no
  641. existing comment, a comment is inserted and aligned.
  642.    Inserting and aligning comments is not the same in Fortran mode as in
  643. other modes.  When a new comment must be inserted, a full-line comment
  644. is inserted if the current line is blank.  On a non-blank line, a
  645. non-standard `!' comment is inserted if you previously specified you
  646. wanted to use them.  Otherwise a full-line comment is inserted on a new
  647. line before the current line.
  648.    Non-standard `!' comments are aligned like comments in other
  649. languages, but full-line comments are aligned differently.  In a
  650. standard full-line comment, the comment delimiter itself must always
  651. appear in column zero.  What can be aligned is the text within the
  652. comment.  You can choose from three styles of alignment by setting the
  653. variable `fortran-comment-indent-style' to one of these values:
  654. `fixed'
  655.      The text is aligned at a fixed column, which is the value of
  656.      `fortran-comment-line-column'.  This is the default.
  657. `relative'
  658.      The text is aligned as if it were a line of code, but with an
  659.      additional `fortran-comment-line-column' columns of indentation.
  660. `nil'
  661.      Text in full-line columns is not moved automatically.
  662.    You can also specify the character to be used to indent within
  663. full-line comments by setting the variable `fortran-comment-indent-char'
  664. to the character you want to use.
  665.    Fortran mode introduces two variables `comment-line-start' and
  666. `comment-line-start-skip' which play for full-line comments the same
  667. roles played by `comment-start' and `comment-start-skip' for ordinary
  668. text-following comments.  Normally these are set properly by Fortran
  669. mode so you do not need to change them.
  670.    The normal Emacs comment command `C-x ;' has not been redefined.  It
  671. can therefore be used if you use `!' comments, but is useless in
  672. Fortran mode otherwise.
  673.    The command `C-c ;' (`fortran-comment-region') turns all the lines
  674. of the region into comments by inserting the string `C$$$' at the front
  675. of each one.  With a numeric arg, the region is turned back into live
  676. code by deleting `C$$$' from the front of each line.  You can control
  677. the string used for the comments by setting the variable
  678. `fortran-comment-region'.  Note that here we have an example of a
  679. command and a variable with the same name; the two uses of the name
  680. never conflict because in Lisp and in Emacs it is always clear from the
  681. context which one is referred to.
  682. File: lemacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Comments,  Up: Fortran
  683. Columns
  684. -------
  685. `C-c C-r'
  686.      Displays a "column ruler" momentarily above the current line
  687.      (`fortran-column-ruler').
  688. `C-c C-w'
  689.      Splits the current window horizontally so that it is 72 columns
  690.      wide.  This may help you avoid going over that limit
  691.      (`fortran-window-create').
  692.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  693. above the current line.  The comment ruler consists of two lines of
  694. text that show you the locations of columns with special significance
  695. in Fortran programs.  Square brackets show the limits of the columns for
  696. line numbers, and curly brackets show the limits of the columns for the
  697. statement body.  Column numbers appear above them.
  698.    Note that the column numbers count from zero, as always in GNU
  699. Emacs.  As a result, the numbers may not be those you are familiar
  700. with; but the actual positions in the line are standard Fortran.
  701.    The text used to display the column ruler is the value of the
  702. variable `fortran-comment-ruler'.  By changing this variable, you can
  703. change the display.
  704.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  705. command which splits the current window horizontally, resulting in a
  706. window 72 columns wide.  When you edit in this window, you can
  707. immediately see when a line gets too wide to be correct Fortran.
  708. File: lemacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  709. Fortran Keyword Abbrevs
  710. -----------------------
  711.    Fortran mode provides many built-in abbrevs for common keywords and
  712. declarations.  These are the same sort of abbrev that you can define
  713. yourself.  To use them, you must turn on Abbrev mode.  *note Abbrevs::..
  714.    The built-in abbrevs are unusual in one way: they all start with a
  715. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  716. mode makes this possible by changing the syntax of semicolon to "word
  717. constituent".
  718.    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
  719. you insert `;c' and then insert a punctuation character such as a space
  720. or a newline, the `;c' changes automatically to `continue', provided
  721. Abbrev mode is enabled.
  722.    Type `;?' or `;C-h' to display a list of all built-in Fortran
  723. abbrevs and what they stand for.
  724. File: lemacs,  Node: Running,  Next: Abbrevs,  Prev: Programs,  Up: Top
  725. Compiling and Testing Programs
  726. ******************************
  727.    The previous chapter discusses the Emacs commands that are useful for
  728. making changes in programs.  This chapter deals with commands that
  729. assist in the larger process of developing and maintaining programs.
  730. * Menu:
  731. * Compilation::        Compiling programs in languages other than Lisp
  732.                         (C, Pascal, etc.)
  733. * Modes: Lisp Modes.   Various modes for editing Lisp programs, with
  734.                        different facilities for running the Lisp programs.
  735. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  736. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  737. * Eval: Lisp Eval.     Executing a single Lisp expression in Emacs.
  738. * Debug: Lisp Debug.   Debugging Lisp programs running in Emacs.
  739. * External Lisp::      Communicating through Emacs with a separate Lisp.
  740. File: lemacs,  Node: Compilation,  Next: Lisp Modes,  Prev: Running,  Up: Running
  741. Running `make', or Compilers Generally
  742. ======================================
  743.    Emacs can run compilers for non-interactive languages like C and
  744. Fortran as inferior processes, feeding the error log into an Emacs
  745. buffer.  It can also parse the error messages and visit the files in
  746. which errors are found, moving point to the line where the error
  747. occurred.
  748. `M-x compile'
  749.      Run a compiler asynchronously under Emacs, with error messages to
  750.      `*compilation*' buffer.
  751. `M-x grep'
  752.      Run `grep' asynchronously under Emacs, with matching lines listed
  753.      in the buffer named `*compilation*'.
  754. `M-x kill-compilation'
  755.      Kill the process made by the M-x compile command.
  756. `M-x kill-grep'
  757.      Kill the running compilation or `grep' subprocess.
  758. `C-x `'
  759.      Visit the next compiler error message or `grep' match.
  760.    To run `make' or another compiler, type `M-x compile'.  This command
  761. reads a shell command line using the minibuffer, then executes the
  762. specified command line in an inferior shell with output going to the
  763. buffer named `*compilation*'.  By default, the current buffer's default
  764. directory is used as the working directory for the execution of the
  765. command; therefore, the makefile comes from this directory.
  766.    When the shell command line is read, the minibuffer appears
  767. containing a default command line (the command you used the last time
  768. you typed `M-x compile').  If you type just RET, the same command line
  769. is used again.  The first `M-x compile' provides `make -k' as the
  770. default.  The default is taken from the variable `compile-command'; if
  771. the appropriate compilation command for a file is something other than
  772. `make -k', it can be useful to have the file specify a local value for
  773. `compile-command' (*note File Variables::.).
  774.    When you start a compilation, the buffer `*compilation*' is
  775. displayed in another window but not selected.  Its mode line displays
  776. the word `run' or `exit' in the parentheses tells you whether
  777. compilation is finished.  You do not have to keep this buffer visible;
  778. compilation continues in any case.
  779.    To kill the compilation process, type `M-x-compilation'.  The mode
  780. line of the `*compilation*' buffer changes to say `signal' instead of
  781. `run'.  Starting a new compilation also kills any running compilation,
  782. as only one can occur at any time.  Starting a new compilation prompts
  783. for confirmation before actually killing a compilation that is running.
  784.    To parse the compiler error messages, type `C-x `' (`next-error').
  785. The character following `C-x' is the grave accent, not the single
  786. quote.  The command displays the buffer `*compilation*' in one window
  787. and the buffer in which the next error occurred in another window.
  788. Point in that buffer is moved to the line where the error was found.
  789. The corresponding error message is scrolled to the top of the window in
  790. which `*compilation*' is displayed.
  791.    The first time you use `C-x `' after the start of a compilation, it
  792. parses all the error messages, visits all the files that have error
  793. messages, and creates markers pointing at the lines the error messages
  794. refer to.  It then moves to the first error message location.
  795. Subsequent uses of `C-x `' advance down the data set up by the first
  796. use.  When the preparsed error messages are exhausted, the next `C-x `'
  797. checks for any more error messages that have come in; this is useful if
  798. you start editing compiler errors while compilation is still going on.
  799. If no additional error messages have come in, `C-x `' reports an error.
  800.    `C-u C-x `' discards the preparsed error message data and parses the
  801. `*compilation*' buffer again, then displays the first error.  This way,
  802. you can process the same set of errors again.
  803.    Instead of running a compiler, you can run `grep' and see the lines
  804. on which matches were found.  To do this, type `M-x grep' with an
  805. argument line that contains the same arguments you would give to `grep'
  806. a `grep'-style regexp (usually in single quotes to quote the shell's
  807. special characters) followed by filenames, which may use wildcard
  808. characters.  The output from `grep' goes in the `*compilation*' buffer.
  809. You can use `C-x `' to find the lines that match as if they were
  810. compilation errors.
  811.    Note: a shell is used to run the compile command, but the shell is
  812. not run in interactive mode.  This means in particular that the shell
  813. starts up with no prompt.  If you find your usual shell prompt making an
  814. unsightly appearance in the `*compilation*' buffer, it means you have
  815. made a mistake in your shell's initialization file (`.cshrc' or `.shrc'
  816. or ...) by setting the prompt unconditionally.  The shell
  817. initialization file should set the prompt only if there already is a
  818. prompt.  Here's how to do it in `csh':
  819.      if ($?prompt) set prompt = ...
  820. File: lemacs,  Node: Lisp Modes,  Next: Lisp Libraries,  Prev: Compilation,  Up: Running
  821. Major Modes for Lisp
  822. ====================
  823.    Emacs has four different major modes for Lisp.  They are the same in
  824. terms of editing commands, but differ in the commands for executing Lisp
  825. expressions.
  826. Emacs-Lisp mode
  827.      The mode for editing source files of programs to run in Emacs Lisp.
  828.      This mode defines `C-M-x' to evaluate the current defun.  *Note
  829.      Lisp Libraries::.
  830. Lisp Interaction mode
  831.      The mode for an interactive session with Emacs Lisp.  It defines
  832.      LFD to evaluate the sexp before point and insert its value in the
  833.      buffer.  *Note Lisp Interaction::.
  834. Lisp mode
  835.      The mode for editing source files of programs that run in other
  836.      dialects of Lisp than Emacs Lisp.  This mode defines `C-M-x' to
  837.      send the current defun to an inferior Lisp process.  *Note
  838.      External Lisp::.
  839. Inferior Lisp mode
  840.      The mode for an interactive session with an inferior Lisp process.
  841.      This mode combines the special features of Lisp mode and Shell mode
  842.      (*note Shell Mode::.).
  843. Scheme mode
  844.      Like Lisp mode but for Scheme programs.
  845. Inferior Scheme mode
  846.      The mode for an interactive session with an inferior Scheme
  847.      process.
  848. File: lemacs,  Node: Lisp Libraries,  Next: Lisp Eval,  Prev: Lisp Modes,  Up: Running
  849. Libraries of Lisp Code for Emacs
  850. ================================
  851.    Lisp code for Emacs editing commands is stored in files whose names
  852. conventionally end in `.el'.  This ending tells Emacs to edit them in
  853. Emacs-Lisp mode (*note Lisp Modes::.).
  854. * Menu:
  855. * Loading::        Loading libraries of Lisp code into Emacs for use.
  856. * Compiling Libraries:: Compiling a library makes it load and run faster.
  857. * Mocklisp::        Converting Mocklisp to Lisp so GNU Emacs can run it.
  858.